# -*- coding: utf-8 -*-
import tkinter as tk  

root = tk.Tk()
 

root.title('Grid_demo')
root.geometry('500x400') 
 
k = 0
for i in range(3):
    for j in range(3):
        tk.Label(root, text=k).grid(row=i, column=j, padx=50, pady=50, ipadx=5, ipady=5)
        k+=1
 
# 第5步，主窗口循环显示
root.mainloop()